<div id="module_compare" class="box">
  <div class="top"><img src="catalog/icon/<?php echo $iconmodule; ?>/basket.png" alt="" /><?php echo $heading_title; ?></div>
  <div class="middle">
    <?php if ($products) { ?>
    <table cellpadding="2" cellspacing="0" style="width: 100%;">
      <?php foreach ($products as $product) { ?>
      <tr>
        <td align="left" valign="top" width="1"><span class="compare_remove" id="<?php echo $product['key']; ?>">&nbsp;</span></td>
        <td align="left" valign="top"><a href="<?php echo $product['href']; ?>"><?php echo $product['name']; ?></a></td>
      </tr>
      <?php } ?>
    </table>
    <div style="padding-top:5px;text-align:center;clear:both;"><a href="<?php echo $compare; ?>"><?php echo $text_compare; ?></a></div>
    <?php } else { ?>
    <div style="text-align: center;"><?php echo $text_empty; ?></div>
    <?php } ?>
  </div>
  <div class="bottom">&nbsp;</div>
</div>
<script type="text/javascript"><!--

function doCompare(myAction, pid) {
		if(pid){
		  var myData = 'action='+myAction+'&product_id='+pid;
		} else {
		  var myData = 'action='+myAction;
		}

		$.ajax({
			type: 'post',
			url: 'index.php?route=module/compare/callback',
			dataType: 'html',
			data: myData,
			success: function (html) {
				$('#module_compare .middle').html(html);
			}

            ,
			complete: function () {

				if(myAction == 'add'){
				var cimage = $('#image').offset();
				var compare  = $('#module_compare').offset();

				$('#image').before('<img src="' + $('#image').attr('src') + '" id="temp" style="position: absolute; top: ' + cimage.top + 'px; left: ' + cimage.left + 'px;" />');

				params = {
					top : compare.top + 'px',
					left : compare.left + 'px',
					opacity : 0.0,
					width : $('#module_compare').width(),
					heigth : $('#module_compare').height()
				};

				$('#temp').animate(params, 'slow', false, function () {
					$('#temp').remove();
				});
				}

			}

		});
	}
$(document).ready(function () {
	$('.compare_remove').live('click', function () {
		if (!confirm('<?php echo $text_confirm; ?>')) {
			return false;
		}
		$(this).removeClass('compare_remove').addClass('compare_remove_loading');
        var id = this.id;
		$.ajax({
			type: 'post',
			url: 'index.php?route=module/compare/callback',
			dataType: 'html',
			data: 'action=remove&product_id=' + id,
			success: function (html) {
				$('.col' + id).hide();
				$('#module_compare .middle').html(html);
				if (getUrlParam('route').indexOf('checkout') != -1) {
					window.location.reload();
				}
			}
		});
	});
});
/*$(document).ready(function () {
	var buttonCompare = 'Compare';
	var productID = '<?php echo $product_id; ?>';
	$('<a id="add_to_compare" class="button" onclick="doCompare(\'add\', '+productID+')"><span>'+buttonCompare+'</span></a>').insertAfter('#add_to_cart');
});*/
//--></script>